﻿<Window xmlns:my="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"  x:Class="MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:EveCharacterBazaar"  
        xml:lang="fr-FR"
    Title="MainWindow" Height="350" Width="525">

    <Window.Resources>
        <CollectionViewSource x:Key="BazaarRowSource" Filter="BazaarRowSource_Filter"  />
        <CollectionViewSource x:Key="BazaarRowSkillSource" Source="{Binding Source={StaticResource BazaarRowSource}, Path=/Skills}"  >
            <CollectionViewSource.GroupDescriptions>
                <PropertyGroupDescription PropertyName="Group" />
            </CollectionViewSource.GroupDescriptions>
        </CollectionViewSource>
    </Window.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="5" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <UniformGrid Columns="3" Height="60" >
            <Button Name="MonitoringBt" Margin="5" Content="Start Monitoring"/>
            <Button Name="ResetDBBt" Margin="5" Content="Reset Database"/>
            <Button Name="SearchBySkillBt" Margin="5" >
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*" />
                        <RowDefinition Height="*" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <TextBlock  Text="Skill" Margin="0,0,5,0"/>
                    <ComboBox  MinWidth="75"  Grid.Column="1" Name="cbxSkill"/>
                    
                    <TextBlock  Grid.Row="1" Text="Level" Margin="0,0,5,0"/>
                    <TextBox  Grid.Row="1" MinWidth="75" Grid.Column="1" Text="1" TextAlignment="Center" Name="txtSkill" />
                </Grid>
            </Button>

        </UniformGrid>

        <ProgressBar Name="PBar" Minimum="0" Maximum="100" Grid.Row="1" Height="20" Orientation="Horizontal"  />

        <DataGrid ItemsSource="{Binding Source={StaticResource BazaarRowSource}}" IsSynchronizedWithCurrentItem="True" AutoGenerateColumns="False" Name="DGrid" Grid.Row="2" IsReadOnly="True" RowDetailsVisibilityMode="VisibleWhenSelected">
            <DataGrid.Columns>

                <DataGridTextColumn  Header="Description" Binding="{Binding Description}"/>

                <DataGridHyperlinkColumn Header="Author" Binding="{Binding AuthorEveBoardUrl}" ContentBinding="{Binding Author}">
                    <DataGridHyperlinkColumn.ElementStyle>
                        <Style TargetType="TextBlock">
                            <EventSetter Event="Hyperlink.Click" Handler="OnHyperlinkClick" />
                        </Style>
                    </DataGridHyperlinkColumn.ElementStyle>
                </DataGridHyperlinkColumn>

                <DataGridHyperlinkColumn Header="Auction" Binding="{Binding Url}" ContentBinding="{Binding RowID}">
                    <DataGridHyperlinkColumn.ElementStyle>
                        <Style TargetType="TextBlock">
                            <EventSetter Event="Hyperlink.Click" Handler="OnHyperlinkClick" />
                        </Style>
                    </DataGridHyperlinkColumn.ElementStyle>
                </DataGridHyperlinkColumn>

                <DataGridTextColumn  Header="Replies Count" Binding="{Binding RepliesCount}"/>

                <DataGridTextColumn  Header="View Count" Binding="{Binding ViewCount}"/>

                <DataGridTextColumn  Header="Like Count" Binding="{Binding LikeCount}"/>

                <DataGridTextColumn  Header="Last Post Date" >
                    <DataGridTextColumn.Binding>
                        <Binding Path="LastPostDate" >
                            <Binding.Converter>
                                <local:DateConverter />
                            </Binding.Converter>
                        </Binding>
                    </DataGridTextColumn.Binding>
                </DataGridTextColumn>

                <DataGridTemplateColumn>
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Button Content="Load" MinWidth="50"  Command="{Binding}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>

                <DataGridTextColumn  Header="DOB" >
                    <DataGridTextColumn.Binding>
                        <Binding Path="DOB" >
                            <Binding.Converter>
                                <local:DateConverter />
                            </Binding.Converter>
                        </Binding>
                    </DataGridTextColumn.Binding>
                </DataGridTextColumn>
                <DataGridTextColumn  Header="Total SP" Foreground="Red" FontWeight="Bold">
                    <DataGridTextColumn.Binding>
                        <Binding Path="TotalSP" StringFormat="N0"  />
                    </DataGridTextColumn.Binding>
                </DataGridTextColumn>

            </DataGrid.Columns>
        </DataGrid>

        <GridSplitter Grid.Row="3" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />

        <Grid  Grid.Row="4">
            
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="5" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>

            <DataGrid AutoGenerateColumns="False" IsReadOnly="True"  ItemsSource="{Binding Source={StaticResource BazaarRowSkillSource}}" IsSynchronizedWithCurrentItem="True">
                <DataGrid.Columns>
                    <DataGridTextColumn Header="Name" Width="SizeToCells" Binding="{Binding Name}" />
                    <DataGridTemplateColumn Header="Level" Width="*" SortMemberPath="Level" >
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <ProgressBar Minimum="0" Maximum="5" Value="{Binding Level}" />
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                    <!--<DataGridTextColumn />-->

                </DataGrid.Columns>
                <DataGrid.GroupStyle>
                    <GroupStyle />
                </DataGrid.GroupStyle>
            </DataGrid>
            
            <GridSplitter Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
            
            <TabControl Grid.Column="2" >
                <TabItem Header="Overview" >
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition />
                        </Grid.RowDefinitions>
                 
                    <DataGrid HeadersVisibility="None" AutoGenerateColumns="False" IsReadOnly="True"  ItemsSource="{Binding ElementName=DGrid, Path=SelectedItem.SkillStat}" IsSynchronizedWithCurrentItem="True">
                        <DataGrid.Columns>
                            <DataGridTextColumn Header="Name" Width="SizeToCells" Binding="{Binding Level}" />
                            <DataGridTemplateColumn Header="Level" Width="*" SortMemberPath="Count" IsReadOnly="True" >
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <ProgressBar Minimum="0" Maximum="100" Value="{Binding Count, Mode=OneWay}" />
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                            <!--<DataGridTextColumn />-->

                        </DataGrid.Columns>
                    </DataGrid>
                        <Viewbox Grid.Row="1" >
                        <TextBlock Text="{Binding ElementName=DGrid, Path=SelectedItem.SkillCost, StringFormat=N0}" />
                 </Viewbox>   </Grid>
                </TabItem>
                <TabItem Header="Ships" />
                <TabItem Header="Fittings" />
                <TabItem Header="Filters">
                    <!--<TabItem.Resources>
                        <XmlDataProvider x:Key="oo" Source="SkillData.xml"  XPath="SkillData/SkillInfo"/>
                    </TabItem.Resources>
                    <DataGrid AutoGenerateColumns="False"  ItemsSource="{Binding  Source={StaticResource oo}}">
                        <DataGrid.Columns>
                            <DataGridTextColumn Header="Type" Binding="{Binding XPath=@Group}" />
                            <DataGridTextColumn Header="Type" Binding="{Binding XPath=@Type}" />
                            <DataGridTextColumn Header="Type" Binding="{Binding XPath=@Type}" />

                        </DataGrid.Columns>

                    </DataGrid>-->
                    <DataGrid Name="SkillFilterDGrid" AutoGenerateColumns="False" >
                        <DataGrid.Columns>
                            <DataGridTextColumn IsReadOnly="True" Header="Skill" Binding="{Binding Skill}" />
                            <DataGridTextColumn IsReadOnly="True" Header="Level" Binding="{Binding Level}"/>
                            <DataGridTemplateColumn >
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <Button Content="Delete" Command="{Binding}" />
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                        </DataGrid.Columns>
                    </DataGrid>
                </TabItem>
            </TabControl>
        </Grid>
      

    </Grid>
</Window>
